//
//  DXStatuseModel.swift
//  weiBoOfSwift
//
//  Created by simon on 15/12/10.
//  Copyright © 2015年 simon. All rights reserved.
//

import UIKit

class DXStatuseModel: NSObject {
    var id:Int64 = 0
//    发微博时间
    var created_at:String?
//    微博内容
    var text:String?
//    微博来源
    var source:String?
//    发微人信息
    var user:DXUserModel?
//    转发微博内容
    var retweeted_status:DXStatuseModel?
//    转发数
    var reposts_count:Int = 0
//    评论数
    var comments_count:Int = 0
//    点赞数
    var attitudes_count:Int = 0
//    微博配图
    var pic_urls:[DXStatuesPictureModel]?
    
    init(dict:[String : AnyObject]) {
        super.init()
        self.setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
        guard let dic = value as? [String : AnyObject] else{
            logPrint("\(key)不是字典")
            return
            }
        user = DXUserModel(dict: dic)

        }else if key == "retweeted_status" {
            guard let dic = value as? [String : AnyObject] else{
                logPrint("\(key)不是字典")
                return
            }
            retweeted_status = DXStatuseModel(dict: dic)
        }else if key == "pic_urls" {
            
            guard let dictArray = value as? [[String : AnyObject]] else{
                logPrint("\(key)不是字典")
                return
            }
            
            var tempArray = [DXStatuesPictureModel]()
            for dict in dictArray{
                let pictureModel = DXStatuesPictureModel(dict: dict)
                tempArray.append(pictureModel)
            }
            pic_urls = tempArray
        
        }else {
        
            super.setValue(value, forKey: key)
        
        }

    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
}
